using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Basic;
namespace eCloudEdit
{
    public partial class SelectRealVarForm : Form
    {
        private Dictionary<string, RealVar> RDList = new Dictionary<string, RealVar>();
        public SelectRealVarForm()
        {
            InitializeComponent();
        }
        public void SetList(Dictionary<string, RealVar> RealList)
        {

            RDList = RealList;


        }
        public Dictionary<string, RealVar> GetList()
        {
            return RDList;
        }
        public string varname
        {
            get
            {
                return this.textBox1.Text;
            }
            set
            {
                this.textBox1.Text = value;
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.OK;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
        }

        private void SelectRealVarForm_Load(object sender, EventArgs e)
        {
            if (RDList != null)
            {
                listView1.Items.Clear();

                //foreach(KeyValuePair<int,string>kvp in myDictionary)

                Dictionary<string, RealVar>.ValueCollection valueCol = RDList.Values;
                foreach (RealVar var in valueCol)
                {
                    ListViewItem item = new ListViewItem();
                    item.SubItems[0].Text=(listView1.Items.Count + 1).ToString();
                    
                    item.SubItems.Add(var.mName);
                    // listViewVar.Items[listViewVar.Items.Count-1].ImageIndex = 0;
                    
                    item.SubItems.Add(var.mDatatype.ToString());
                    item.SubItems.Add(var.mDesc);
                    listView1.Items.Add(item);
                  
                }
                listView1.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
            }
        }
        private string sdatatype = "";
        public string datatype
        {
            get
            {
                return sdatatype;
            }
            set
            {
                sdatatype = value;
            }
        }
        private void listView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listView1.SelectedItems.Count != 1)		// no selection
                return;
            ListViewItem selitem = listView1.SelectedItems[0];          
            varname = selitem.SubItems[1].Text;
            sdatatype = selitem.SubItems[2].Text;
         
        }
    }
}